package database

import (
	"QImages/global"
	"github.com/gin-gonic/gin"
	"github.com/jinzhu/gorm"
	_ "github.com/jinzhu/gorm/dialects/mysql"
	"log"
)

var DB *gorm.DB

func init() {
	db, err := gorm.Open("mysql", global.Config.MysqlDsn)
	if err != nil {
		log.Panic(err)
	}
	if gin.Mode() == "release" {
		db.LogMode(false)
	} else {
		db.LogMode(true)
	}
	DB = db
}
